package com.chnagli06.method_more;

public class valuetransferTest {
    public static void main(String[] args) {
        valuetransferTest vt = new valuetransferTest();
        //基本数据类型---------传值
        int n = 10;//实参
        vt.add(n);
        System.out.println(n);//10





        //对象类型------------传址
        Car c1 = new Car();
        c1.age = 10;
        vt.add(c1);
        System.out.println(c1.age);//11


        int a = 10;
        int b = 20;
        vt.swap(a,b);
        System.out.println(a+","+b);

    }











    //方法


    public void  add(int n) {//形参
        n++;
    }
    public void add (Car c){
        c.age++;
    }
    public void swap (int a, int b) {
        int temp = a;
        a = b;
        b = temp;
    }
}
class Car {
    int age;
}
